local Chars={["mc"]=0,["sc"]=0,["ml"]=0,["sl"]=0,["main"]="",["scnd"]=""};
 
function XBarKlass_OnEvent(this,event)
-- ChatFrame1:AddMessage("XBar-Klass : "..event);
	if (event=="LOADING_END") then
		this:RegisterEvent("UNIT_CLASS_CHANGED");
		this:RegisterEvent("UNIT_LEVEL");
	end
	Chars["mc"],Chars["sc"]=UnitClass("player");
	Chars["ml"],Chars["sl"]=UnitLevel("player");
-- Output
	local usrtxt={[1]=XBar["KlassV1"],[2]=XBar["KlassV2"]};
	local output="";
	for i=1,2 do
		usrtxt[i],_=XBar_StrReplace(usrtxt[i],"%[MLVL%]",tostring(Chars["ml"]));
		usrtxt[i],_=XBar_StrReplace(usrtxt[i],"%[MCLASS%]",tostring(Chars["mc"]));
		usrtxt[i],_=XBar_StrReplace(usrtxt[i],"%[SLVL%]",tostring(Chars["sl"]));
		usrtxt[i],_=XBar_StrReplace(usrtxt[i],"%[SCLASS%]",tostring(Chars["sc"]));
	end
	if (XBar["KlassT1"]==true) then output=usrtxt[1]; end
	if (XBar["KlassT2"]==true) then
		if (XBar["KlassT1"]==true) then output=output.."\n"..usrtxt[2]; else output=usrtxt[2]; end
	end
	XBarKlass_F_Text:SetText(output);
-- EoL
end
